extends EnemyState


var screensize

# Called when the node enters the scene tree for the first time.
func _ready():
	screensize = get_viewport().size

func update():
	# 掉头
	if enemy.position.x == screensize.x:
		enemy.velocity.x = -1
		enemy.get_node("Position2D").scale.x = -1
	if enemy.position.x == 0:
		enemy.velocity.x = 1
		enemy.get_node("Position2D").scale.x = 1
	if enemy.velocity.length()>0:
		enemy.velocity = enemy.velocity.normalized() * enemy.EnemyRunSpeed
